Fix executing commands in Eshell using "env" with no local variables
authorJim Porter <jporterbugs@gmail.com>
Wed, 25 Sep 2024 18:59:32 +0000 (11:59 -0700)
committerJim Porter <jporterbugs@gmail.com>
Mon, 30 Sep 2024 01:22:45 +0000 (18:22 -0700)
* lisp/eshell/esh-var.el (eshell/env): Throw 'eshell-replace-command' as
needed.

* test/lisp/eshell/esh-var-tests.el
(esh-var-test/local-variables/env/no-locals): New test (bug#73479).

lisp/eshell/esh-var.el
test/lisp/eshell/esh-var-tests.el

index f0270aca92c853d7663e898a56b71e5e4ba00af1..1b54f1862be7b473d66bd477d9b636a2161e3e35 100644 (file)
@@ -436,7 +436,8 @@ the values of nil for each."
      :usage "[NAME=VALUE]... [COMMAND]...")
    (if args
        (or (eshell-parse-local-variables args)
-           (eshell-named-command (car args) (cdr args)))
+           (throw 'eshell-replace-command
+                  `(eshell-named-command ,(car args) ',(cdr args))))
      (eshell-with-buffered-print
        (dolist (setting (sort (eshell-environment-variables) 'string-lessp))
          (eshell-buffered-print setting "\n"))))))
index 6b0e225f05f58e81c4c9d0023680c6cacdbeb8ef..7b29e4a21db2f3accedd29d75fa28f34cdda3bed 100644 (file)
@@ -669,6 +669,11 @@ nil, use FUNCTION instead."
    (eshell-match-command-output "env VAR=hello env" "VAR=hello\n")
    (should (equal (getenv "VAR") "value"))))
 
+(ert-deftest esh-var-test/local-variables/env/no-locals ()
+  "Test that \"env command\" works like \"command\"."
+  (with-temp-eshell
+   (eshell-match-command-output "env echo hi" "\\`hi\n")))
+
 \f
 ;; Variable aliases